package org.moonshot.cvm;

public class CVMContext extends ChattyStack
{
	private final Object[] fields;
	public final int length;
	
	public CVMContext(ChattyVM aVM, int len)
	{
		this(aVM, len, null, 0);
	}
	
	public CVMContext(ChattyVM aVM, int len, ChattyStack aInit, int params)
	{
		length = len;
		fields = new Object[len];
		
		int i = 0;
		for(i = 0; i < params; i++)
			fields[i] = aInit.at (params - i);
		for(i = params; i < len; i++)
			fields[i] = aVM.NIL;
	}
	
	public void put(int idx, Object val)
	{
		fields[idx] = val;
	}
	
	public Object get(int idx)
	{
		return fields[idx];
	}
}
